
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
    <title>课程安排</title>
    <script type="text/javascript" src="<%=basePath%>static/js/jquery-1.11.3.min.js"></script>

    <link rel="stylesheet" href="<%=basePath%>static/css/bootstrap-theme.css">
    <%--    <link rel="stylesheet" href="<%=basePath%>static/css/pintuer.css">--%>


    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">

    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>static/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>static/js/jqPaginator.js"></script>
</head>
<body >
<div id="window" style="position: absolute;left: 30%;top:20%;width: 400px;height: 370px;background-color: #a6e1ec;display: none;">
    <center>
        <input type="hidden" name="id" id="id">lid,l.address,lstarttime,iendtime,tname,coursename
        <span >课程id：  </span><input type="text" name="lid" id="sid" readonly = "true"><br>
        <span >上课地点：</span><input type="text" name="address" id="address" readonly = "true"><br>
        <span >上课时间：</span><input type="text" name="lstarttime" id="lstarttime" readonly = "true"><br>
        <span>下课时间：</span><input type="text" name="iendtime" id="iendtime" readonly = "true"><br>
        <span>上课教师：</span><input type="text" name="tname" id="tname" readonly = "true"><br>
        <span>课程名：</span><input type="text" name="coursename" id="coursename" readonly = "true"><br>
    </center>
</div>
<table class="table table-hover" border="1" width="50%">
    <tr>
        <td>课程id</td>
        <td>上课地点</td>
        <td>上课时间</td>
        <td>下课时间</td>
        <td>上课教师</td>
        <td>课程名</td>
    </tr>
    <tbody id="tb">
    </tbody>
</table>
</body>

<script>
    //文档加载后要执行的函数
    $(document).ready(function () {
        loadData();
    });

    function loadData() {
//jquery的ajax请求方法

        $.ajax({
            url: "<%=basePath%>manage/selectLessionAll",
            async: false,//同步请求（默认）
            type: "POST",
            dataType: "json",
            success: function (data) {
                console.log(data);
//使用jquery形式遍历
// $.each(data.list, function (n, val) {
                $("#tb").html("");
                if(data.length>0){
                    //使用jquery形式遍历
                    $.each(data,function(n,val){
                        var html = "";
                        html += "<tr>" +
                            "<td>" + val.lid+ "</td>" +
                            "<td>" + val.address + "</td>" +
                            "<td>" + val.lstarttime+ "</td>" +
                            "<td>" + val.iendtime+ "</td>" +
                            "<td>" + val.teacher.tname+ "</td>" +
                            "<td>" + val.course.coursename+ "</td>" +
                            "</tr>";
                        $("#tb").append(html);
                    });
                }else{
                    $("#tb").append("<tr><td colspan=8 align=\"center\">暂时没有数据哦，快去添加一条吧</td></tr>");
                }
            },
            error:function(){
                alert("服务器出错！");
            }
        });

    }
</script>
</body>
</html>
